Skip to content

Conversation

rmehri01
Copy link
Contributor

@rmehri01 rmehri01 commented Jun 7, 2025

Adds autogenerated compiler flag stubs to the unstable book by building rustc, passing it's path to unstable-book-gen, and using that to call the compiler with -Zhelp and create a similar Features that is used for library and lang stubs.

Example:

# `combine_cgu`

combine CGUs into a single one

This feature has no tracking issue, and is therefore likely internal to the compiler, not being intended for general use.

------------------------

Closes #141525

@rustbot
Copy link
Collaborator

rustbot commented Jun 7, 2025

Failed to set assignee to jyn514: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jun 7, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 7, 2025

Error: Parsing assign command in comment failed: ...'' | error: specify user to assign to at >| ''...

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

@workingjubilee
Copy link
Member

r? compiler

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 7, 2025
@rust-log-analyzer

This comment has been minimized.

@rmehri01 rmehri01 force-pushed the gen-compiler-flags branch from 42a4c2d to 2cfd494 Compare June 7, 2025 02:26
@lcnr
Copy link
Contributor

lcnr commented Jun 10, 2025

r? compiler

@rustbot rustbot assigned compiler-errors and unassigned lcnr Jun 10, 2025
@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 11, 2025

📌 Commit 2cfd494 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 11, 2025
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 12, 2025
…piler-errors

docs: autogenerate compiler flag stubs based on -Zhelp

Adds autogenerated compiler flag stubs to the unstable book by building rustc, passing it's path to `unstable-book-gen`, and using that to call the compiler with `-Zhelp` and create a similar `Features` that is used for library and lang stubs.

Example:

```md
# `combine_cgu`

combine CGUs into a single one

This feature has no tracking issue, and is therefore likely internal to the compiler, not being intended for general use.

------------------------
```

Closes rust-lang#141525
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 12, 2025
…piler-errors

docs: autogenerate compiler flag stubs based on -Zhelp

Adds autogenerated compiler flag stubs to the unstable book by building rustc, passing it's path to `unstable-book-gen`, and using that to call the compiler with `-Zhelp` and create a similar `Features` that is used for library and lang stubs.

Example:

```md
# `combine_cgu`

combine CGUs into a single one

This feature has no tracking issue, and is therefore likely internal to the compiler, not being intended for general use.

------------------------
```

Closes rust-lang#141525
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 12, 2025
…piler-errors

docs: autogenerate compiler flag stubs based on -Zhelp

Adds autogenerated compiler flag stubs to the unstable book by building rustc, passing it's path to `unstable-book-gen`, and using that to call the compiler with `-Zhelp` and create a similar `Features` that is used for library and lang stubs.

Example:

```md
# `combine_cgu`

combine CGUs into a single one

This feature has no tracking issue, and is therefore likely internal to the compiler, not being intended for general use.

------------------------
```

Closes rust-lang#141525
bors added a commit that referenced this pull request Jun 12, 2025
Rollup of 9 pull requests

Successful merges:

 - #138016 (Added `Clone` implementation for `ChunkBy`)
 - #140770 (add `extern "custom"` functions)
 - #141162 (refactor  `AttributeGate` and `rustc_attr!` to emit notes during feature checking)
 - #141474 (Add `ParseMode::Diagnostic` and fix multiline spans in diagnostic attribute lints)
 - #141947 (Specify that "option-like" enums must be `#[repr(Rust)]` to be ABI-compatible with their non-1ZST field.)
 - #142135 (docs: autogenerate compiler flag stubs based on -Zhelp)
 - #142252 (Improve clarity of `core::sync::atomic` docs about "Considerations" in regards to CAS operations)
 - #142337 (miri: add flag to suppress float non-determinism)
 - #142353 (compiler: Ease off the accelerator on `unsupported_calling_conventions`)

r? `@ghost`
`@rustbot` modify labels: rollup
@matthiaskrgr
Copy link
Member

@bors r-
guess this failed here #142399 (comment)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 12, 2025
@alex-semenyuk
Copy link
Member

@rmehri01
Thanks for your contribution.
Form wg-triage. Any updates on this PR?

@rmehri01
Copy link
Contributor Author

rmehri01 commented Aug 9, 2025

@rmehri01 Thanks for your contribution. Form wg-triage. Any updates on this PR?

Hey! Sorry I'm not exactly sure what went wrong here, it seems like it has to do something with getting the output of -Zhelp on aarch64 windows, is there something else we should try instead?

Edit: nvm I think I messed up the host argument to builder.compiler

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rmehri01 rmehri01 force-pushed the gen-compiler-flags branch from bc500ae to 00ce4f5 Compare August 9, 2025 20:49
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rmehri01 rmehri01 force-pushed the gen-compiler-flags branch from bd8cdf2 to 0e7711e Compare August 9, 2025 21:33
@rmehri01
Copy link
Contributor Author

rmehri01 commented Aug 9, 2025

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 9, 2025
@bors
Copy link
Collaborator

bors commented Aug 10, 2025

☔ The latest upstream changes (presumably #145210) made this pull request unmergeable. Please resolve the merge conflicts.

@rmehri01 rmehri01 force-pushed the gen-compiler-flags branch from 0e7711e to 8e0034d Compare August 10, 2025 18:42
@rust-log-analyzer

This comment has been minimized.

@rmehri01 rmehri01 force-pushed the gen-compiler-flags branch 2 times, most recently from d633a45 to 91ee21b Compare August 10, 2025 19:42
@bors
Copy link
Collaborator

bors commented Aug 11, 2025

☔ The latest upstream changes (presumably #145011) made this pull request unmergeable. Please resolve the merge conflicts.

@rmehri01 rmehri01 force-pushed the gen-compiler-flags branch from 91ee21b to 3104e57 Compare August 11, 2025 12:53
@compiler-errors
Copy link
Member

r? bootstrap

@@ -112,14 +122,47 @@ fn copy_recursive(from: &Path, to: &Path) {
}
}

fn collect_compiler_flags(rustc_path: impl AsRef<Path>) -> Features {
let mut rustc = Command::new(rustc_path.as_ref());
rustc.arg("-Zhelp");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than running -Zhelp and then trying to parse that, maybe we can parse the options! macro (

)? I think that has all the -Z flags. That would also give you a file/line to link to. I'm not sure how valuable that is, but if it is, that seems like the way to get that information.

I'm OK with sticking with -Z/-C parsing since the syntax is both fairly simple and controlled by us, though.

We'd likely also want (perhaps in a separate PR) to enforce that all the -C flags in codegen options (also in the linked file) have documentation in the non-unstable book. That could be done in tidy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be nice to have the file/line to link to, do you mean just literally reading and parsing the rust source file to do that or is there a better way to go about it?

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 21, 2025
@rmehri01 rmehri01 force-pushed the gen-compiler-flags branch from 3104e57 to 41eb772 Compare August 23, 2025 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

autogenerate compiler flag stubs in the unstable book